package com.hmdp.utils;

import com.hmdp.dto.UserDTO;

/**
 * 创建ThreadLoad
 */
public class UserHolder {
    private static final ThreadLocal<UserDTO> tl = new ThreadLocal<>();
    //添加到线程里面
    public static void saveUser(UserDTO user){
        tl.set(user);
    }
    // 获取用户信息
    public static UserDTO getUser(){
        return tl.get();
    }
    // 移除信息
    public static void removeUser(){
        tl.remove();
    }
}
